package heima.lm.oschina.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import heima.lm.oschina.R;
import heima.lm.oschina.ui.activity.ActivitiesActivity;
import heima.lm.oschina.ui.activity.FindPeopleActivity;
import heima.lm.oschina.ui.activity.FriendCircleActivity;
import heima.lm.oschina.ui.activity.RockActivity;
import heima.lm.oschina.ui.view.DiscoverItemView;

/**
 * Created by herenxue on 2017/4/2.
 * 发现的Fragment
 */

public class DiscoverFragment extends Fragment {


    @BindView(R.id.div_friend_circle)
    DiscoverItemView discoverFriendView;
    @BindView(R.id.div_find)
    DiscoverItemView discoverFindView;
    @BindView(R.id.div_activities)
    DiscoverItemView discoverActivitiesView;
    @BindView(R.id.div_scan)
    DiscoverItemView discoverScanView;
    @BindView(R.id.div_rock)
    DiscoverItemView discoverRockView;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_discover, container, false);
        ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        //好友圈
        discoverFriendView.setImageResource(R.drawable.icon_explore_friends);
        discoverFriendView.setTextContent("好友圈");

        //找人
        discoverFindView.setImageResource(R.drawable.icon_explore_finduser);
        discoverFindView.setTextContent("找人");

        //活动
        discoverActivitiesView.setImageResource(R.drawable.icon_explore_event);
        discoverActivitiesView.setTextContent("活动");

        //扫一扫
        discoverScanView.setImageResource(R.drawable.icon_explore_scan);
        discoverScanView.setTextContent("扫一扫");

        //摇一摇
        discoverRockView.setImageResource(R.drawable.icon_explore_shake);
        discoverRockView.setTextContent("摇一摇");
        initEvent();
    }

    private void initEvent() {
        discoverFriendView.setItemOnClickListener(new DiscoverItemView.DisItemOnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), FriendCircleActivity.class);
                startActivity(intent);
            }
        });
        discoverFindView.setItemOnClickListener(new DiscoverItemView.DisItemOnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), FindPeopleActivity.class);
                startActivity(intent);
            }
        });
        discoverActivitiesView.setItemOnClickListener(new DiscoverItemView.DisItemOnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent("heima.lm.oschina.activities.activity"));
            }
        });
        discoverScanView.setItemOnClickListener(new DiscoverItemView.DisItemOnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(getContext(), "扫一扫功能正在努力开发中···", Toast.LENGTH_SHORT).show();
            }
        });
        discoverRockView.setItemOnClickListener(new DiscoverItemView.DisItemOnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), RockActivity.class);
                startActivity(intent);
            }
        });
    }
}
